import axios from "axios";
let host='http://localhost:3080/book'

export const getAll=async (keyword)=>{ 
    // console.log(keyword);    
    let data;
    if(keyword){
        data=await axios.get(`${host}?keyword=${keyword}`)
    }
    else{
        data=await axios.get(host)
    }
    
    return data.data
}
export const addItem=async (obj)=>{ 
    let data=await axios.post(host,obj)
    return data.data
}
export const editItem=async (id,obj)=>{ 
    let data=await axios.put(`${host}/${id}`,obj)
    return data.data
}

export const delItem=async (id)=>{ 
    let data=await axios.get(host)
    return data.data
}
export const getByid=async(id)=>{
    let data=await axios.get(`${host}/${id}`)
    return data.data
}